<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>转至现金钱包</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no"/>
	<meta http-equiv="Access-Control-Allow-Origin" content="*">
	<meta http-equiv="X-UA-Compatible" content="ie=edge"/>
	<link rel="stylesheet" href="../css/base.css" />
	<link rel="stylesheet" href="../css/tixian.css" />
	<script src="../js/jquery-2.2.3.min.js"></script>
	<script type="text/javascript" src="../js/rem.js"></script>
	<script type="text/javascript" src="../js/common.js"></script>
	<style>
		.tixian_inp {
			border-bottom: 1px solid #CCCCCC !important;
			font-size: .18rem;
			margin-top: .1rem;
		}
		.tixian_btn {
			margin-top: .27rem;
		}
	</style>
</head>
<body>
<div class="header">
	<a href="javascript:history.back(-1)"><img src="../img/g_next.png" alt="" /></a>
	转至现金钱包
</div>
<div class="tixian_main">
	<!--<div class="tixian_fangShi">-->
	<!--<img class="FS" src="../img/g_tixian_wx.png" alt="" />-->
	<!--<div class="name">-->
	<!---->
	<!--<p class="two">微信零钱</p>-->
	<!--</div>-->
	<!--<img class="right" src="../img/icon-right.png" alt="" />-->
	<!--</div>-->
	<div class="tixian_jinE" style="height: auto;">
		<p class="tixian_TS">请输入转账金额</p>
		<input class="tixian_inp" type="text" placeholder="￥" />
		<p class="tixian_XZ tixian_XZ1">利率：<span style="float: none"></span></p>
		<p class="tixian_XZ tixian_XZ2">到手金额：<span style="float: none"></span></p>
	</div>
</div>
<!--<p class="tixian_DZ">提现免手续费，预计1-3个工作日到账</p>-->
<input type="button" value="下一步" class="tixian_btn" />
<div class="overlay">
	<!--<div class="tixian_FS_XZ">-->
	<!--<p class="title">提现到</p>-->
	<!--<lu class="tixian_FS_XZ_ul">-->
	<!--<li class="tixian_FS_XZ_li">-->
	<!--<img src="../img/g_tixian_afb.png" alt="" />-->
	<!--<span>支付宝账户（3756）</span>-->
	<!--</li>-->
	<!--<li class="tixian_FS_XZ_li">-->
	<!--<img src="../img/g_tixian_wx.png" alt="" />-->
	<!--<span>微信零钱</span>-->
	<!--</li>-->
	<!--<li class="tixian_FS_XZ_li">-->
	<!--<img src="../img/g_tixian_yh.png" alt="" />-->
	<!--<span>招商银行（3756）</span>-->
	<!--</li>-->
	<!--</lu>-->
	<!--<div class="tixian_tj">-->
	<!--<img  src="../img/G_tixian_tj.png"/>-->
	<!--<span>添加新卡</span>-->
	<!--</div>-->
	<!--</div>-->
	<div class="tixian_password">
		<p class="title">输入支付密码</p>
		<img class="gb" src="../img/g_tixian_gb.png" alt="" />
		<div class="input f_l">
			<input class="MM inpVal1" style="border-left:1px solid #909090;" type="password" class="" maxlength="1">
			<input class="MM inpVal2" type="password" maxlength="1">
			<input class="MM inpVal3" type="password" maxlength="1">
			<input class="MM inpVal4" type="password" maxlength="1">
			<input class="MM inpVal5" type="password" maxlength="1">
			<input class="MM inpVal6" type="password" maxlength="1">
		</div>
		<a href="#" class="WJ_password">忘记密码?</a>
	</div>

</div>
</body>
<script>
    var _lv = 0.1;
    $.ajax({
        url: SURL + '/jfd/sysConfigs/getSysConfigs',
        async: false,
        success: function (res) {
            _lv = res.changeRate / 100;
        }
    });
    // console.log(_lv, '-------------------------');
    $('.tixian_XZ1 span').text(_lv * 100 + '%');
    $('.tixian_inp').blur(function () {
        var _val = $(this).val();
        var sxf = _val * _lv;
        var num = _val - sxf;
        $('.tixian_XZ2 span').text(num);
    });
    $(function(){
        $('.tixian_fangShi').click(function(){
            $('.overlay').show();
            $('.tixian_FS_XZ').show();
        });
        $('.tixian_btn').click(function(){
            var ze = parseInt(localStorage.getItem('xiaofeizonge'));
            if (parseInt($('.tixian_inp').val()) == 0) {
                alert('提现金额不允许为0')
            }else if (parseInt($('.tixian_inp').val()) == '') {
                alert('提现金额不允许为空')
            }else if (parseInt($('.tixian_inp').val()) <= ze) {
                $('.overlay').show();
                $('.tixian_password').show();
            }else {
                alert('消费钱包余额不足');
            }
        });
        $('.tixian_password .gb').click(function(){
            $('.overlay').hide();
        });
        $('.tixian_FS_XZ_li').click(function(){
            var src = $(this).find("img").attr("src");
            var _text = $(this).find("span").text();
            $('.tixian_fangShi .FS').attr("src",src);
            $('.tixian_fangShi .name .two').text(_text);
            $('.overlay').hide();
        })
    })
</script>
<script>

    /*模拟支付宝的密码输入形式*/
    (function(window, document) {
        var active = 0,
            inputBtn = document.getElementsByClassName('MM');
        for(var i = 0; i < inputBtn.length; i++) {
            inputBtn[i].addEventListener('click', function() {
                inputBtn[active].focus();
            }, false);
            inputBtn[i].addEventListener('focus', function() {
                this.addEventListener('keyup', listenKeyUp, false);
            }, false);
            inputBtn[i].addEventListener('blur', function() {
                this.removeEventListener('keyup', listenKeyUp, false);
            }, false);
        }

        /*监听键盘的敲击事件*/
        function listenKeyUp() {
            if(!isNaN(this.value) && this.value.length != 0) {
                if(active < 5) {
                    console.log(active);
                    active += 1;
                }else if(active == 5){
                    console.log(333);
                    var int  = document.getElementsByClassName('MM ')
                    var srt = ''
                    for(i =0;i<int.length;i++){
                        srt += int[i].value
                    }
                    console.log(srt);
                    $.ajax({
                        url: SURL + '/jfd/account/changeCash',
                        type: 'POST',
                        data: {
                            userId: localStorage.getItem('userId'),
                            paypassword: srt,
                            changeCash: $('.tixian_inp').val(),
                            type: 2,
                        },
                        success: function (res) {
                            if (res.code == 0) {
                                localStorage.setItem('xfje1', $('.tixian_XZ2 span').text());
                                window.location.href = 'xiaofeitixianjieguo.html';
                            }else {
                                alert(res.msg);
                            }
                        }
                    })
                }
                inputBtn[active].focus();
            } else if(this.value.length == 0) {
                console.log(2222);
                if(active > 0) {
                    active -= 1;
                }
                inputBtn[active].focus();
            }
        }


    })(window, document);




</script>
</html>
